import { _roomlist } from '../../common/meeting'
const computedBehavior = require('miniprogram-computed')
const app = getApp()
Component({
  behaviors: [computedBehavior],
  data: {
    list: [],
    filters: [],
    filterIndex: 0,
    filter: ''
  },
  computed: {
    filtedList() {
      return this.data.list.filter(item => 
        this.data.filter ? item.RoomType == this.data.filter: true
        )
    }
  },
  methods: {
    totalQuery() {
      app.loading('加载中')
      _roomlist().then(res => {
        wx.hideLoading()
        let list = res.data.Meeting_Room_list
        this.setData({
          list
        })
      }).catch(err => {
        console.log(err)
        wx.hideLoading()
        wx.showModal({
          title: '对不起',
          content: JSON.stringify(err) || '网络错误，请稍后再试',
          showCancel: false
        })
      })
    },
    onLoad(options) {
    },
    onReady() { },
    onShow() {
      app.memberReadyCb = () => {
        this.totalQuery()
      }
      app.fansReadyCb = () => {
        app.checkMember()
      }
      app.init()
    },
    onShareAppMessage() {
      return app.shareInfo
    }
  }
})